﻿using System;

namespace StockSharp.AlfaDirect
{
    using System.Security.Cryptography;

    using Ecng.Common;

    using StockSharp.Algo;

    /// <summary>
    /// Класс для генерации уникальных transaction id.
    /// </summary>
    internal sealed class RngCryptoTransactionIdGenerator : TransactionIdGenerator
    {
		/// <summary>
		/// Получить следующий transaction id.
		/// </summary>
		/// <returns>
		/// Следующий transaction id.
		/// </returns>
        public override long GetNextId()
        {
            var rng = new RNGCryptoServiceProvider();
            var buffer = new byte[sizeof(long)];
    
            rng.GetBytes(buffer);

            return BitConverter.ToUInt32(buffer, 0).To<long>();
        }
    }
}
